   app.controller('actCtrl',function($scope,$http,$routeParams){ 
   	if ($routeParams.id==11) {
   		$('.f_a').css('display','none')
	$('.f_myaccount_list_title').removeClass('f_myaccount_green')
	$('.f_myaccount_content11').css('display','block')
	$('.f_myaccount_list_title').eq(10).addClass('f_myaccount_green')
   	} else if($routeParams.id==2){
   			$('.f_a').css('display','none')
	$('.f_myaccount_list_title').removeClass('f_myaccount_green')
	$('.f_myaccount_content2').css('display','block')
	$('.f_myaccount_list_title').eq(1).addClass('f_myaccount_green')
   	}
 	$scope.data10=[{ding:'410522199105071118',data:'2017-06-24',status:'已完成',img:'../img/f_myaccount/b1.png',name:'云南昭通丑苹果6个装',guige:'6个装',number:'3',score:'180'},{ding:'410522199105071119',data:'2017-06-24',status:'已完成',img:'../img/f_myaccount/b1.png',name:'云南昭通丑苹果6个装',guige:'6个装',number:'2',score:'120'},{ding:'410522199105071110',data:'2017-06-24',status:'已完成',img:'../img/f_myaccount/b1.png',name:'云南昭通丑苹果6个装',guige:'6个装',number:'1',score:'60'},{ding:'410522199105071111',data:'2017-06-24',status:'已完成',img:'../img/f_myaccount/b1.png',name:'云南昭通丑苹果6个装',guige:'6个装',number:'1',score:'60'}]
 	
 //订单
  $http.get('../php/f_dingdan.php?').success(function(data){
          	   $scope.data11=data
          	   console.log( $scope.data11)
          	   for(var j=0;j<data.length;j++){
          	   }
          	  
          })
 	$scope.data12=[{data:'2017-6-24 13:20:07',change:'+100',come:'消费赠送'},{data:'2017-6-24 13:20:07',change:'+100',come:'消费赠送'},{data:'2017-6-24 13:20:07',change:'-200',come:'积分兑换'},{data:'2017-6-24 13:20:07',change:'+100',come:'消费赠送'},{data:'2017-6-24 13:20:07',change:'+100',come:'消费赠送'},{data:'2017-6-24 13:20:07',change:'-200',come:'积分兑换'}]
       $scope.data13=[{img:'../img/f_myaccount/shoucang/3.png',name:'新西兰佳沛黄金奇异果',miaoshu:'花蜜般的甘甜百吃不厌',xianjia:'¥28.80',yuanjia:'¥40.00'},{img:'../img/f_myaccount/shoucang/2.png',name:'新西兰佳沛黄金奇异果',miaoshu:'花蜜般的甘甜百吃不厌',xianjia:'¥28.80',yuanjia:'¥40.00'}]
 	$scope.f_cancelshou=function(n){
 		$scope.data13.splice(n,1);
 	}
 	
 	//评星
 	$('.f_xinxin1').each(function(i,e){
	$(e).on('click',function(){
		$('.f_xinxin1').attr('src','../img/f_myaccount/hui.png');
		for (var j=0;j<=i;j++) {			
			$('.f_xinxin1').eq(j).attr('src','../img/f_myaccount/hong.png');
		}
	})
})
$('.f_xinxin').each(function(i,e){
	$(e).on('click',function(){
		$('.f_xinxin').attr('src','../img/f_myaccount/hui.png');
		for (var j=0;j<=i;j++) {			
			$('.f_xinxin').eq(j).attr('src','../img/f_myaccount/hong.png');
		}
	})
})
 $('.f_xinxin2').each(function(i,e){
	$(e).on('click',function(){
		$('.f_xinxin2').attr('src','../img/f_myaccount/hui.png');
		for (var j=0;j<=i;j++) {			
			$('.f_xinxin2').eq(j).attr('src','../img/f_myaccount/hong.png');
		}
	})
})	
 	$('.f_xinxin3').each(function(i,e){
	$(e).on('click',function(){
		$('.f_xinxin3').attr('src','../img/f_myaccount/hui.png');
		for (var j=0;j<=i;j++) {			
			$('.f_xinxin3').eq(j).attr('src','../img/f_myaccount/hong.png');
		}
	})
})
 //晒图1
//       function preview2(file) {
//          var reader = new FileReader();
//          reader.readAsDataURL(file);
//          reader.onload = function(e) {
//              var $img = $('<img>').attr("src", e.target.result);
//              $('.f_shai').empty().append($img);
//          }
//          
//      }        
//      $(function() {
//          $('.fff').change(function(e) {
//              var file = e.target.files[0]              
//              preview2(file);
//          })
//      }) 

 //晒图2
//       function preview2(file) {
//          var reader = new FileReader();
//          reader.readAsDataURL(file);
//          reader.onload = function(e) {
//              var $img = $('<img>').attr("src", e.target.result);
//              $('.f_filediv_touxiang').empty().append($img);
//          }
//          
//      }        
//      $(function() {
//          $('.f_gaitou').change(function(e) {
//              var file = e.target.files[0]              
//              preview2(file);
//          })
//      }) 	
   $scope.f_zhifu=function(){
   	  localStorage.setItem('address','河南省安阳市殷都区');
          localStorage.setItem('money','4008');
   }
   	
 	
  ca("f_canvas1");
ca("f_canvas2");
ca("f_canvas3");
function ca(id){
	var canvas = document.getElementById(id);

function randomNum(min, max) {
	return Math.floor(Math.random() * (max - min) + min);
}
/**生成一个随机色**/
function randomColor(min, max) {
	var r = randomNum(min, max);
	var g = randomNum(min, max);
	var b = randomNum(min, max);
	return "rgb(" + r + "," + g + "," + b + ")";
}
drawPic();
document.getElementsByClassName("noSeen")[0].onclick = function(e) {
	e.preventDefault();
	drawPic();
}

/**绘制验证码图片**/
function drawPic() {

	var width = canvas.width;
	var height = canvas.height;
	var ctx = canvas.getContext('2d');
	ctx.textBaseline = 'bottom';

	/**绘制背景色**/
	ctx.fillStyle = randomColor(180, 240); //颜色若太深可能导致看不清
	ctx.fillRect(0, 0, width, height);
	/**绘制文字**/
	var str = 'ABCEFGHJKLMNPQRSTWXY123456789';
	var yzm = '';
	for (var i = 0; i < 4; i++) {
		var txt = str[randomNum(0, str.length)];
		ctx.fillStyle = randomColor(50, 160); //随机生成字体颜色
		ctx.font = randomNum(20, 30) + 'px SimHei'; //随机生成字体大小
		var x = 3 + i * 20;
		var y = randomNum(25, 30);
		var deg = randomNum(-45, 45);
		//修改坐标原点和旋转角度
		ctx.translate(x, y);
		ctx.rotate(deg * Math.PI / 180);
		ctx.fillText(txt, 0, 0);
		yzm = yzm + txt;
		//恢复坐标原点和旋转角度
		ctx.rotate(-deg * Math.PI / 180);
		ctx.translate(-x, -y);
	}
	canvas.className = yzm;
	/**绘制干扰线**/
	for (var i = 0; i < 3; i++) {
		ctx.strokeStyle = randomColor(40, 180);
		ctx.beginPath();
		ctx.moveTo(randomNum(0, width), randomNum(0, height));
		ctx.lineTo(randomNum(0, width), randomNum(0, height));
		ctx.stroke();
	}
	/**绘制干扰点**/
	for (var i = 0; i < 30; i++) {
		ctx.fillStyle = randomColor(0, 255);
		ctx.beginPath();
		ctx.arc(randomNum(0, width), randomNum(0, height), 1, 0, 2 * Math.PI);
		ctx.fill();
	}
}
}
   var sheng = document.getElementById('sheng');
	var shi = document.getElementById('shi');
	var xian = document.getElementById('xian');

	function shengFun(){
		var l = provinceList.length;
		var shtml = '';
		for(var i=0;i<l;i++){
			shtml+='<option value='+i+'>'+provinceList[i].name+'</option>';
		}
		sheng.innerHTML = shtml;
		cityFun(0);
	}

	function cityFun(n){
		var city = provinceList[n].cityList;
		var l = city.length;
		var shtml = '';
		for(var i=0;i<l;i++){
			shtml+='<option value='+i+'>'+city[i].name+'</option>';
		}
		shi.innerHTML = shtml;
		xianFun(n,0);
	}

	function xianFun(n,m){
		var city = provinceList[n].cityList[m].areaList;
		var l = city.length;
		var shtml = '';
		for(var i=0;i<l;i++){
			shtml+='<option>'+city[i]+'</option>';
		}
		xian.innerHTML = shtml;
	}

	//设置默认
	shengFun();
	
	//点击效果
	sheng.onchange=function(){
		var n = this.selectedIndex;
		cityFun(n);
		shi.onchange=function(){
			var m = this.selectedIndex;
			xianFun(n,m);
		};
	};
	
$('.f_myaccount_list_title').each(function(i,e){
	$(e).on('click',function(){
		var str='.f_myaccount_content'+(i+1)
		$('.f_a').css('display','none')
		$('.f_myaccount_list_title').removeClass('f_myaccount_green')
		$(str).css('display','block')
		$('.f_myaccount_list_title').eq(i).addClass('f_myaccount_green')
	})
})
$('.f_myaccount1-1_t_b5>p:eq(0)').on('click',function(){
	$('.f_a').css('display','none')
	$('.f_myaccount_list_title').removeClass('f_myaccount_green')
	$('.f_myaccount_content5').css('display','block')
	$('.f_myaccount_list_title').eq(4).addClass('f_myaccount_green')
})
$('.f_myaccount1-1_t_b5>p:eq(1)').on('click',function(){
	$('.f_a').css('display','none')
	$('.f_myaccount_list_title').removeClass('f_myaccount_green')
	$('.f_myaccount_content1-1').css('display','block')
	$('.f_myaccount_list_title').eq(0).addClass('f_myaccount_green')
})


$scope.f_chakan=function(){
	$('.f_a').css('display','none')
	$('.f_myaccount_list_title').removeClass('f_myaccount_green')
	$('.f_myaccount_content4-1').css('display','block')
	$('.f_myaccount_list_title').eq(3).addClass('f_myaccount_green')
}
$scope.f_del=function(n){
	 $scope.data10.splice(n,1);
}



$('.f_sex').each(function(i,e){
	$(e).on('click',function(){
		$('.f_sex').attr('src','../img/f_myaccount/circle0.png')
	$(e).attr('src','../img/f_myaccount/circle1.png')
})
})
//修改头像
        function preview2(file) {
            var reader = new FileReader();
            reader.readAsDataURL(file);
            reader.onload = function(e) {
                var $img = $('<img>').attr("src", e.target.result);
                $('.f_filediv_touxiang').empty().append($img);
            }
            
        }        
        $(function() {
            $('.f_gaitou').change(function(e) {
                var file = e.target.files[0]              
                preview2(file);
            })
        })  
        //晒图
                function preview2(file) {
            var reader = new FileReader();
            reader.readAsDataURL(file);
            reader.onload = function(e) {
                var $img = $('<img>').attr("src", e.target.result);
                $('.f_filediv_touxiang').empty().append($img);
            }
            
        }        
        $(function() {
            $('[type=file]').change(function(e) {
                var file = e.target.files[0]
               
                preview2(file);
            })
        })
$('.f_myaccount_ct61-change').on('click',function(){
	$('.f_myaccount_content6').css('display','none')
	$('.f_myaccount_content6-2').css('display','block')
})
$('.f_myaccount62_bA4').on('click',function(){
	$('.f_myaccount_content6-2').css('display','none')
	$('.f_myaccount_content6-3').css('display','block')
})
$('.f_myaccount62_bB4').on('click',function(){
	$('.f_myaccount_content6-3').css('display','none')
	$('.f_myaccount_content6-4').css('display','block')
})
$('.f_myaccount2_buttom_top_right').on('click',function(){
	$('.f_a').css('display','none')
	$('.f_myaccount_content2-0').css('display','block')
})
$scope.f_fdingxq=function(){
	$('.f_myaccount_content2').css('display','none')
	$('.f_myaccount_content2-1').css('display','block')
}
$('.f_myaccount_content11-look').on('click',function(){
	$('.f_myaccount_content11').css('display','none')
	$('.f_myaccount_content11-1').css('display','block')
})
$scope.f_pinjia=function(){
	$('.f_myaccount_content2').css('display','none')
		$('.f_myaccount_content2-2').css('display','block')
	
}
$('.f_myaccount1_right').on('click',function(){
	$('.f_myaccount_content1-1').css('display','none')
	$('.f_myaccount_content1-2').css('display','block')
})
//地址管理添加
$('.f_myaccount7_right').on('click',function(){
	$('.f_a').css('display','none')
	$('.f_myaccount_content7').css('display','block')
})
$('.f_myaccount7_right1').on('click',function(){
	$('.f_a').css('display','none')
	$('.f_myaccount_content7').css('display','block')
})
//设置默认地址属性
$('.f_myaccount71_buttom-five img').on('click',function(){
	$('.f_myaccount71_buttom-five img').attr('src','../img/f_myaccount/circle1.png')
})


//修改密码提示

$('.f_pass').change(function(){
	if ($('.f_pass').val().length<6) {
		$('.f_role:eq(0)').css('opacity','1')
	}else{
		$('.f_role:eq(0)').css('opacity','0')
	}
})
$('.f_passagin').change(function(){
	if ($('.f_passagin').val().length<6) {
		$('.f_role:eq(1)').css('opacity','1')
	}else{
		$('.f_role:eq(1)').css('opacity','0')
	}
})
$('.f_yan').change(function(){
	if ($('.f_yan').val().length!=4) {
		$('.f_role:eq(2)').css('opacity','1')
	}else{
		$('.f_role:eq(2)').css('opacity','0')
	}
})
$('.f_telyan').change(function(){
	if ($('.f_telyan').val().length!=6) {
		$('.f_role:eq(3)').css('opacity','1')
	}else{
		$('.f_role:eq(3)').css('opacity','0')
	}
})

//选择充值金额
var contain='';
$('.f_myaccount5_buttom2 div').each(function(i,e){
	$(e).on('click',function(){
		$('.f_myaccount5_buttom2 div').css({background:'white',borderColor:'rgb(212,212,212)'})
		$(e).css({background:'rgb(244,255,242)',borderColor:'rgb(100,161,48)'})
		switch (i){
			case 0:{contain=500
				break;}
				case 1:{contain=1000
				break;}
				case 2:{contain=2000
				break;}
			default:{contain=0
				break;}				
		}
	
	})
})
//本地存储账号
//localStorage.tel=15517211938;
//获取账号信息

	 //获取时获取账户信息
	$http.get('../php/f_account-detail.php?tel='+localStorage.tel).success(function(data){
		$scope.data1=data;
//		console.log(localStorage.tel)
       totle();
	})
	//修改密码提交
	$('.f_commitchange').on('click',function(){
		var fps=$('.f_pass').val()
	if($('.f_role').css('opacity')==1){
		alert('有要求不符合')
	}else if($('.f_pass').val()!=$('.f_passagin').val()){
		alert('两次密码不一致请重新填写密码')
	}else{
		$('.f_success').animate({'opacity':'1'},1000,function(){
			$http.get('../php/f_password.php?password='+fps+'&tel='+localStorage.tel).success(function(data){console.log(data)})
		})
		$('.f_myaccount10_buttom-left input').val('')
	}
})
	//充值提交
	$('.f_myaccount5_buttom5').on("click",function(){	
		   $scope.a=1
			//获取当前时间
	   $scope.now=new Date().getTime();
localStorage.money=contain;
	$scope.arr=[];
$http.get('../php/f_myaccount.php?tel='+localStorage.tel+'&money='+localStorage.money+"&time="+$scope.now).success(function(data){
		$scope.data2=data;
		$scope.totle=0;
		for (var i=0;i<data.length;i++ ){				
			$scope.totle=$scope.totle+(data[i].money-0);
			 $scope.arr.push($scope.totle);
			 
		}
		totle();

	})  
  	$('.f_myaccount_list_title').removeClass('f_myaccount_green')
   $('.f_a').css('display','none');
  $('.f_myaccount_content1-2').css('display','block');
  $('.f_myaccount_list_title').eq(0).addClass('f_myaccount_green')
  //时间
  $http.get('../php/f_time.php?tel='+localStorage.tel).success(function(data){
	$scope.data4=data;
	console.log($scope.data4)
})
  
})	


	//总钱
	function totle(){
				$http.get('../php/f_totlemoney.php?tel='+localStorage.tel).success(function(data){
		$scope.data3=data;
	})
	}
	
	     //提交个人资料
     $('.f_myaccount6_b6').on('click',function(){
     	   var name= $('.nickname').val();//存名字
     	   var sex=''; //存性别
     	   var arr1=[],dt='';//存日期
     	   var phone=0;
             $('.f_sex').each(function(i,e){
             if($(e).attr('src').indexOf('1')>0){
                   if (i==0) {
                  	sex='男';
                   } else{
                 	sex='女';
                    }
            }
             })
             
             $('.dt').each(function(i,e){
             	arr1.push($(e).val())
             })
            dt=arr1.join("-")
            phone=$('.phone').val();
          $http.get('../php/f_person.php?name='+name+"&sex="+sex+"&data="+dt+"&phone="+phone).success(function(data){
                alert('修改成功') 
          })
             
     })
     //添加收货地址
     $('.f_myaccount71_buttom-sex').on('click',function(){
     	var ff='';
     	var getuser=$('#name').val();//收货人姓名
     	var getarea=$('#sheng option:selected').text()+$('#shi option:selected').text()+$('#xian option:selected').text();//收货人地区	
     	var getaddress=$('#address').val();//收货人地址
     	var gettel=$('#cellphone').val();//收货人手机
     	var getfixed=$('#fixed1').val()+'-'+$('#fixed2').val();//收货人固话
          if ($('.f_moren').attr('src','../img/f_myaccount/circle1.png')) {
          	ff=true;
          }
     	var fregex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$";
     	if ($('#name').val()=='') {
     		alert('请填写姓名');
     	}else if($('#address').val()==""){
     		alert('请填写详细地址');
     	}else if($('#cellphone').val()==""){
     		alert('请填写联系电话');
     	}else if($('#cellphone').val().search(fregex)<0){
     		alert('手机格式不对哦')
     	}else if($('#fixed1').val()==""||$('#fixed2').val()==''){
     		alert('请填写固话');
     	}else{
     		$http.get("../php/f_getuser.php?tel="+localStorage.tel+"&username="+getuser+"&usertel="+gettel+"&usertel2="+getfixed+"&address="+getaddress+"&area="+getarea+"&moren="+ff).success(function(data){
     			$scope.data6=data
     			
     		})
     		$('.f_myaccount71_buttom input').val('')
     		$('.f_a').css('display','none')
     		$('.f_myaccount_content7-0').css('display','block')
     	}
    
     })
     $scope.f_getuserdel=function(n){
     	$scope.data6.splice(n,1);
     }
     
     $scope.f_cancel=function(n){
     	$scope.data11.splice(n,1);
     }
     //收藏
     $http.get('../php/f_shoucang.php?').success(function(data){
          	   $scope.data5=data
          })
	$scope.del=function(n){
		    $scope.data5.splice(n,1);
	}
	
})

